//
//  RegisterCell.m
//  HTHappySale
//
//  Created by 创维海通 on 2017/9/20.
//  Copyright © 2017年 zxyywy. All rights reserved.
//

#import "RegisterCell.h"
@interface RegisterCell()<UITextFieldDelegate>
{
    NSMutableArray *titileArr;
}
@property (strong, nonatomic) IBOutlet UILabel *titleLal;
@property (strong, nonatomic) IBOutlet UITextField *inputText;
@property (strong, nonatomic) UIButton *clickBtn;

@end

@implementation RegisterCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    titileArr = [NSMutableArray arrayWithObjects:@"昵称", @"区域", @"真实姓名", @"手机号" ,nil];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)configureCell:(NSInteger)index{
    _titleLal.text = titileArr[index-1];
    _inputText.tag = 100 + index;
    if(index == 1){
        _inputText.text = nickname;
    }else if (index == 2)
    {
//        _inputText.enabled = NO;
        _inputText.alpha = 0;
        _inputText.hidden = YES;
        _clickBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _clickBtn.frame = CGRectMake(110, 0, SCREEN_WIDTH - 140, 44);
        [_clickBtn addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
        [_clickBtn setTitleColor: [UIColor blackColor] forState:UIControlStateNormal];
        _clickBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        
        _clickBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
        _clickBtn.titleLabel.font = HTCFLabelFont(14);

        _clickBtn.tag = 112;
//        _clickBtn.alpha = 0.01;
        [self addSubview:_clickBtn];
    }else if (index == 4) {
        _inputText.text = mobileStr;
        _inputText.enabled = NO;
    }
}

#pragma mark -Action
- (void)clickAction
{
    if ([_cellDelegate respondsToSelector:@selector(clickCell)]) {
        [_cellDelegate performSelector:@selector(clickCell) withObject:self];
    }
}

#pragma mark -textFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
//{
//    NSLog(@"%@",event);
////    [self.contentView endEditing:YES];
//}

@end
